home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kio / chmodjob.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-01-15  |  3.6 KB  |  110 lines

  1. // -*- c++ -*-
  2. /* This file is part of the KDE libraries
  3.     Copyright (C) 2000 David Faure <faure@kde.org>
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20.  
  21. #ifndef __kio_chmodjob_h__
  22. #define __kio_chmodjob_h__
  23.  
  24. #include <kurl.h>
  25. #include <qstring.h>
  26.  
  27. #include <kio/global.h>
  28. #include <kio/job.h>
  29. #include <kfileitem.h>
  30.  
  31. namespace KIO {
  32.  
  33.     /**
  34.      * This job changes permissions on a list of files or directories,
  35.      * optionally in a recursive manner.
  36.      * @see KIO::chmod()
  37.      */
  38.     class KIO_EXPORT ChmodJob : public KIO::Job
  39.     {
  40.         Q_OBJECT
  41.     public:
  42.     /**
  43.      * Create new ChmodJobs using the KIO::chmod() function.
  44.      */
  45.         ChmodJob( const KFileItemList & lstItems,  int permissions, int mask,
  46.                   int newOwner, int newGroup,
  47.                   bool recursive, bool showProgressInfo );
  48.  
  49.     protected:
  50.         void chmodNextFile();
  51.  
  52.     protected slots:
  53.  
  54.         virtual void slotResult( KIO::Job *job );
  55.         void slotEntries( KIO::Job * , const KIO::UDSEntryList & );
  56.         void processList();
  57.  
  58.     private:
  59.         struct ChmodInfo
  60.         {
  61.             KURL url;
  62.             int permissions;
  63.         };
  64.         enum { STATE_LISTING, STATE_CHMODING } state;
  65.         int m_permissions;
  66.         int m_mask;
  67.         int m_newOwner;
  68.         int m_newGroup;
  69.         bool m_recursive;
  70.         KFileItemList m_lstItems;
  71.         QValueList<ChmodInfo> m_infos;
  72.     protected:
  73.     virtual void virtual_hook( int id, void* data );
  74.     private:
  75.     class ChmodJobPrivate* d;
  76.     };
  77.  
  78.  
  79.     /**
  80.      * Creates a job that changes permissions/ownership on several files or directories,
  81.      * optionally recursively.
  82.      * This version of chmod uses a KFileItemList so that it directly knows
  83.      * what to do with the items. TODO: a version that takes a KURL::List,
  84.      * and a general job that stats each url and returns a KFileItemList.
  85.      *
  86.      * Note that change of ownership is only supported for local files.
  87.      *
  88.      * Inside directories, the "x" bits will only be changed for files that had
  89.      * at least one "x" bit before, and for directories.
  90.      * This emulates the behavior of chmod +X.
  91.      *
  92.      * @param lstItems The file items representing several files or directories.
  93.      * @param permissions the permissions we want to set
  94.      * @param mask the bits we are allowed to change.
  95.      * For instance, if mask is 0077, we don't change
  96.      * the "user" bits, only "group" and "others".
  97.      * @param newOwner If non-empty, the new owner for the files
  98.      * @param newGroup If non-empty, the new group for the files
  99.      * @param recursive whether to open directories recursively
  100.      * @param showProgressInfo true to show progess information
  101.      * @return The job handling the operation.
  102.      */
  103.     KIO_EXPORT ChmodJob * chmod( const KFileItemList& lstItems, int permissions, int mask,
  104.                       QString newOwner, QString newGroup,
  105.                       bool recursive, bool showProgressInfo = true );
  106.  
  107. }
  108.  
  109. #endif
  110.